/*************************************
Copyright 2011 Chinua Iloabachie, Pradnya Khutafale, Siyi Liu, Junichi Suzuki, and The University of Massachusetts, Boston (http://code.google.com/p/tabletuml/)


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 
*************************************/


package touchMe.Util;

import java.io.File;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.widget.Toast;
import touchMe.baseClass.Constants;

public class Mail {

	public static void sendDiagram(Context context,String emailTo,String fileName){
		String msg=" \n Find attached a diagram "+fileName+". \n\n - powdered by TouchMe";
		SendFile(context, emailTo, "", "Diagram from TouchMe", msg, fileName);
	}
	private static void SendFile(Context context, String emailTo, String emailCC,
	        String subject, String emailText, String fileName){
        try {
            Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
            picMessageIntent.setType("text/uxf");
            File downloadedPic = new File(fileName);
            picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
            
            //picMessageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailTo);
            picMessageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,subject);
            picMessageIntent.putExtra(android.content.Intent.EXTRA_TEXT,emailText);
    
            context.startActivity(Intent.createChooser(picMessageIntent,"Send diagram..."));
        } catch (Exception e) {
            Log.e(Constants.TAG, "SendFile() failed to start activity.", e);
            Toast.makeText(context, "No handler", Toast.LENGTH_LONG).show();
        }
    }
}
